<%@ page language="java" contentType="text/html; charset=UTF-8" import="java.sql.*" errorPage=""%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .content {
        letter-spacing: 0.3em;
        margin-top: 70px;
        text-align: center;
    }
    .title {
        font-size: 30px;
        background-color: rgb(204, 255, 204);
    }
    .ra1 {
        margin-top: 40px;
        text-align: center;
        font-size: 25px;
        font-weight: 700;
        text-align: left;
    }
    .ra2 {
        text-align: center;
        font-size: 25px;
        font-weight: 700;
        text-align: left;
    }
    .subm {
        margin-top: 30px;
        text-align: center;
        position: relative;
    }
    .left {
        position: absolute;
		left: 40%;
    }
    .right {
        position: absolute;
        right: 40%;
    }
</style>
<body>
	<%@ include file="inc.jsp" %>
	<jsp:useBean id="LogBean" scope="session" class="Bean.dbConn"/>
<%
session.setAttribute("testpe","SAS");

		ResultSet rs = null;
		ResultSet rb = null;
		
		Integer num = (Integer)session.getAttribute("num");
		Integer list = (Integer)session.getAttribute("list");
		
		String right1 = request.getParameter("right1");
		String left1 = request.getParameter("left1");
		
		
		session.setAttribute("flag",0);
		
		if(right1 != null || left1 != null) {
			session.setAttribute("flag",1);
		}
		
		if(left1 != null) {
		if(list != 1) {
		Integer temp = (Integer)session.getAttribute("temp");
		
		num=new Integer(num.intValue() - temp);
		list=new Integer(list.intValue() - 1);
		session.setAttribute("num",num);
		session.setAttribute("list",list);
		}
		}
		
		Integer flag = (Integer)session.getAttribute("flag");
		
		
		if(list != null) {
			if(list > 19) {
		response.sendRedirect("report.jsp");
		} 
	}
		
		if(num == null) {
		num=new Integer(0);
		session.setAttribute("num",num);
		}
		if(list == null) {
		list=new Integer(1);
		session.setAttribute("list",list);
		}
		
		if(flag == 1) {
		String myname = request.getParameter("check");
		rb = LogBean.executeQuery("SELECT * FROM sas_kind where rowno =" + "'"+ list +"'");
		rb.next();
		
		if("A".equals(myname)) {
		session.setAttribute("temp",Integer.parseInt(rb.getString("A")));
		num=new Integer(num.intValue() + Integer.parseInt(rb.getString("A")));
		list=new Integer(list.intValue() + 1);
		session.setAttribute("num",num);
		session.setAttribute("list",list);
		}
		
		if("B".equals(myname)) {
		session.setAttribute("temp",Integer.parseInt(rb.getString("B")));
		num=new Integer(num.intValue() + Integer.parseInt(rb.getString("B")));
		list=new Integer(list.intValue() + 1);
		session.setAttribute("num",num);
		session.setAttribute("list",list);
		}
		
		if("C".equals(myname)) {
		session.setAttribute("temp",Integer.parseInt(rb.getString("C")));
		num=new Integer(num.intValue() + Integer.parseInt(rb.getString("C")));
		list=new Integer(list.intValue() + 1);
		session.setAttribute("num",num);
		session.setAttribute("list",list);
		}
		
		if("D".equals(myname)) {
		session.setAttribute("temp",Integer.parseInt(rb.getString("D")));
		num=new Integer(num.intValue() + Integer.parseInt(rb.getString("D")));
		list=new Integer(list.intValue() + 1);
		session.setAttribute("num",num);
		session.setAttribute("list",list);
		}
		}
		
		rs = LogBean.executeQuery("SELECT * FROM sas where rowno =" + "'"+ list +"'");
		rs.next();
		

%>
<%=list%>
<%=num%>
<%=flag%>
    <div class="content">
        <span class="title"><%=list%>、<%=rs.getString("content")%><br></span>
    </div>
    <form action="SAS.jsp" method="POST" name="mytest">
        <table border="0" align="center">
            <tr class="ra1">
                <td><input type="radio" name="check" value="A"></td>
                <td>A.<%=rs.getString("A")%></td>
                <td><input type="radio" name="check" value="B"></td>
                <td>B.<%=rs.getString("B")%></td>
            </tr>
            <tr class="ra2">
                <td><input type="radio" name="check" value="C"></td>
                <td>C.<%=rs.getString("C")%></td>
                <td><input type="radio" name="check" value="D"></td>
                <td>D.<%=rs.getString("D")%></td>
            </tr>
        </table>
        <div class="subm">
            <input type="submit" value="上一题" name="left1" class="left">
            <input type="submit" value="下一题" name="right1" class="right">
        </div>
    </form>
</body>
</html>